using System;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpDbLink : IComparable<OracleLpDbLink>
	{
		protected OracleLpName m_vDatabase;

		protected OracleLpName m_vDomain;

		protected OracleLpName m_vConnectionQualifier;

		public OracleLpName Database
		{
			get
			{
				return m_vDatabase;
			}
			set
			{
				m_vDatabase = value;
			}
		}

		public OracleLpName Domain
		{
			get
			{
				return m_vDomain;
			}
			set
			{
				m_vDomain = value;
			}
		}

		public OracleLpName ConnectionQualifier
		{
			get
			{
				return m_vConnectionQualifier;
			}
			set
			{
				m_vConnectionQualifier = value;
			}
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder(128);
			stringBuilder.Append(m_vDatabase.DbName);
			if (m_vDomain != null && m_vDomain.DbName != null)
			{
				stringBuilder.Append('.');
				stringBuilder.Append(m_vDomain.DbName);
			}
			if (m_vConnectionQualifier != null && m_vConnectionQualifier.DbName != null)
			{
				stringBuilder.Append('@');
				stringBuilder.Append(m_vConnectionQualifier.DbName);
			}
			return stringBuilder.ToString();
		}

		public int CompareTo(OracleLpDbLink other)
		{
			if (this == other)
			{
				return 0;
			}
			if (other == null)
			{
				return 1;
			}
			return ToString().CompareTo(other.ToString());
		}
	}
}
